package com.freight.msg.enums;

import lombok.Getter;

/**
 * @author hytma
 */

@Getter
public enum MessStatusEnum {
    MESS_GEN(0, "待回复消息"),
    MESS_REPLAY(1, "已回复消息"),
    MESS_OVER(-1, "取消消息");
    Integer code;
    String name;


    MessStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getName(int index) {
        for (MessStatusEnum orderStatus : MessStatusEnum.values()) {
            if (orderStatus.getCode() == index) {
                return orderStatus.name;
            }
        }
        return null;
    }

    public static MessStatusEnum findByCode(Integer code) {
        for (MessStatusEnum orderStatusEnum : MessStatusEnum.values()) {
            if (code.equals(orderStatusEnum.code)) {
                return orderStatusEnum;
            }
        }
        throw new RuntimeException("状态不存在");
    }

}
